package com.pinyoumei.app.view.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;

import com.pinyoumei.app.R;


public class MallDetailDialog extends Dialog{
    private Context context;
    //布局文件id
    private int layoutResID;



    public MallDetailDialog(Context context, int layoutResID) {
        //这个决定dialog的样式
        super(context, R.style.dialogStyle);
        this.context = context;
        this.layoutResID = layoutResID;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //获取一个窗口
        Window window = getWindow();
        //设置窗口的位置
        window.setGravity(Gravity.BOTTOM);
        //设置窗口进入时的动画特效
        window.setWindowAnimations(R.style.bottom_menu_animation);
        //获取窗口的属性赋值给layoutParams
        WindowManager.LayoutParams layoutParams = window.getAttributes();
        layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
        window.setAttributes(layoutParams);//设置窗口的属性
        setCanceledOnTouchOutside(true);
        setContentView(layoutResID);

    }

    @Override
    public void show() {
        super.show();
        /**
         * 设置宽度全屏，要设置在show的后面
         */
        WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
        layoutParams.gravity = Gravity.BOTTOM;
        layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
        layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
        getWindow().getDecorView().setPadding(0, 0, 0, 0);
        getWindow().setAttributes(layoutParams);
    }


}
